<%
	/**
	 *  mainFrame 系统主框架页
	 * 
	 * @author  李荣华
	 * @version v1.0
	 * @date    2017-12-31
	 * @since   JSP 2.3.1
	 */
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="at" uri="http://www.jketing.com/at"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>		
		<title>云南华讯信息科技有限公司协同办公平台</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />	
		<link rel="stylesheet" type="text/css" href="<at:url css="mainFrame.css"/>" />
		<link rel="stylesheet" type="text/css" href="<at:url css="desktop.css"/>" />	
		<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/jquery.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/common.js?t=1"></script>
		<script type="text/javascript" src="<at:url js="mainFrame.js"/>"></script>		
		<script type="text/javascript">
			function display(id1,id2){
			    var obj1 = document.getElementById(id1);
			    var obj2 = document.getElementById(id2);
			    if(obj2.style.display != "none"){
			      obj2.style.display = "none";			       
			    }	
			    if(obj1.style.display != "block") {
			    	obj1.style.display = "block";	
				} else {
					obj1.style.display = "none";
				}			      
			}

			function calendar(){
				setTimeout(function(){
				   window.location.href = "Business/CoolCalendar.HTML";
				},0);
			}
			  
		    function GetRadioValue(RadioName){
				var obj;    
			    obj=document.getElementsByName(RadioName);
			    if(obj!=null){
			    	var i;
			        for(i=0;i<obj.length;i++){
			        	if(obj[i].checked){
			            	return obj[i].value;            
			            }
			        }
			    }
			    return null;
			}
			  
			function changeRole(radioName) {				
		   		var id = GetRadioValue(radioName);
				var url = "${pageContext.request.contextPath}/changeRole?roleId=" + id + "&t="
						+ new Date().getTime();
				$.get(url, function(data) {
					if('success'==data){
						alert('角色切换成功，刷新后将进入新角色功能！');
						window.location.reload();
					}
				});
			}
			
			function switchThemes(obj) {							
				var url = "service!setThemes?enName=" + obj.id + "&t="+ new Date().getTime();
				$.get(url, function(data) {
					var url = "${rootPath}/Themes/" + obj.id + "/css/mainFrame.css";								
					$("#mainFrame")[0].href = url;					
					url = "${rootPath}/Themes/" + obj.id + "/css/list.css";										
					eachThemes(document, url);
				});
			}
		
			function eachThemes(doc, url) {
				for ( var j = 0; j < doc.styleSheets.length; j++) {
					var link = doc.styleSheets(j);		
					if (link.href.indexOf("list.css") > -1) {
						link.href = url;
						break;
					}										
				}				
				for ( var i = 0; i < doc.frames.length; i++) {					
					eachThemes(doc.frames[i].document, url);
				}				
			}
			
			function exit() {
				if(window.confirm("您确定要退出吗?")){
					setTimeout(function(){
					    window.location.href = "${pageContext.request.contextPath}/shiro/logout";
					},0);
				}
			} 

			var popup_dragging = false;
			var popup_target;
			var popup_mouseX;
			var popup_mouseY;
			var popup_mouseposX;
			var popup_mouseposY;
			var popup_oldfunction;
			function popup_display(x) {
				var win = window.open();
				for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
			}
			// ----- popup_mousedown -------------------------------------------------------
			function popup_mousedown(e)	{
				var ie = navigator.appName == "Microsoft Internet Explorer";
				if ( ie && window.event.button != 1) return;
				if (!ie && e.button != 0) return;
				popup_dragging = true;
				popup_target = this['target'];
				popup_mouseX = ie ? window.event.clientX : e.clientX;
				popup_mouseY = ie ? window.event.clientY : e.clientY;
				if (ie)
				popup_oldfunction = document.onselectstart;
				else popup_oldfunction = document.onmousedown;
				if (ie)
				document.onselectstart = new Function("return false;");
				else document.onmousedown = new Function("return false;");
			}
			// ----- popup_mousemove -------------------------------------------------------
			function popup_mousemove(e)	{
				if (!popup_dragging) return;
				var ie = navigator.appName == "Microsoft Internet Explorer";
				var element = document.getElementById(popup_target);
				var mouseX = ie ? window.event.clientX : e.clientX;
				var mouseY = ie ? window.event.clientY : e.clientY;
				element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px';
				element.style.top = (element.offsetTop +mouseY-popup_mouseY)+'px';
				popup_mouseX = ie ? window.event.clientX : e.clientX;
				popup_mouseY = ie ? window.event.clientY : e.clientY;
			}
			// ----- popup_mouseup ---------------------------------------------------------
			function popup_mouseup(e) {
				if (!popup_dragging) return;
				popup_dragging = false;
				var ie = navigator.appName == "Microsoft Internet Explorer";
				var element = document.getElementById(popup_target);
				if (ie)
				document.onselectstart = popup_oldfunction;
				else document.onmousedown = popup_oldfunction;
			}
			// ----- 关闭 ------------------------------------------------------------
			function popup_exit(e) {
				var ie = navigator.appName == "Microsoft Internet Explorer";
				var element = document.getElementById(popup_target);
				popup_mouseup(e);
				element.style.visibility = 'hidden';
				element.style.display = 'none';
			}
			// ----- 弹出显示 ------------------------------------------------------------
			function popup_show() {				
				element = document.getElementById('popup');
				drag_element = document.getElementById('popup_drag');
				exit_element = document.getElementById('popup_exit');
				element.style.position = "absolute";
				element.style.visibility = "visible";
				element.style.display = "block";
				element.style.left = (document.documentElement.scrollLeft+popup_mouseposX-100)+'px';
				element.style.top = (document.documentElement.scrollTop +popup_mouseposY+50)+'px';
				drag_element['target'] = 'popup';
				drag_element.onmousedown = popup_mousedown;
				exit_element.onclick = popup_exit;
			}
			// ----- popup_mousepos --------------------------------------------------------
			function popup_mousepos(e) {
				var ie = navigator.appName == "Microsoft Internet Explorer";
				popup_mouseposX = ie ? window.event.clientX : e.clientX;
				popup_mouseposY = ie ? window.event.clientY : e.clientY;
			}
			// ----- Attach Events ---------------------------------------------------------
			if (navigator.appName == "Microsoft Internet Explorer") {
				document.attachEvent('onmousedown', popup_mousepos);
			}else {
				 document.addEventListener('mousedown', popup_mousepos, false);
			}
			if (navigator.appName == "Microsoft Internet Explorer") {
				document.attachEvent('onmousemove', popup_mousemove);
			}else {
				document.addEventListener('mousemove', popup_mousemove, false);
			} 
			if (navigator.appName == "Microsoft Internet Explorer") {
				document.attachEvent('onmouseup', popup_mouseup);
			}else {
				document.addEventListener('mouseup', popup_mouseup, false);
			} 
			
			$(document).ready(function() {
				$(window).resize(function() {
					resetSize();
				});
			});
			
			/**
			 * 浏览器大小改变时的处理函数
			 */
			function resetSize(){
				//重新定位左箭头的位置
				var sidaHeight = $("#left_2").css("height");
				sidaHeight = parseInt(sidaHeight);
				imgHeight = sidaHeight/2-80;
				$("#but").css("margin-top",imgHeight+"px");
				setTimeout(function(){
					resizeIFrame();
				},100);
				
			}
			
			/**
			 * 浏览器大小改变时重新设置所有IFrame的值(递归调用)
			 */
			function resizeIFrame(){ 
				var height = $("#tab").css("height");
				$("iframe").each(function(){
					$(this).css("height",height);
					 if(this.contentWindow.resizeIFrame){
						this.contentWindow.resizeIFrame();
					} 
				});
			}
			
			/**
			 *点击按钮显示、隐藏目录菜单
			 */
			function menuControl(){		
				var left_1 = document.getElementById("left_1");				
				var left_2 = document.getElementById("left_2");	
				var tab = document.getElementById("tab");
				//var LButton = document.getElementById("LButton");	
				if (left_1.style.display == "none") {
					left_1.style.display = "block";
					left_1.style.left="0px";
					left_1.style.width="135px";
					left_2.style.left="135px";
					left_2.style.width="18px";
					tab.style.left="153px";
					//LButton.style.backgroundImg= "Themes/BlueStyle/image/Zbiao_05_1_03.gif";无效
					$("#LButton").attr("style","background:url('<at:url image='Zbiao_05_2_03.gif'/>') no-repeat;");
				} else {
					left_1.style.display = "none";				
					left_1.style.left="0px";
					left_1.style.width="0px";
					left_2.style.left="0px";					
					tab.style.left="18px";
					//LButton.style.backgroundImg= "Themes/BlueStyle/image/Zbiao_05_2_03.gif";
					$("#LButton").attr("style","background:url('<at:url image='Zbiao_05_1_03.gif'/>') no-repeat;");
				}	
			}
			
			//隐藏LOGO
			function T_flex() {
				var logo=document.getElementById("logo_top"); // 顶部logo区哉
				var meun=document.getElementById("menu");
				var left_1=document.getElementById("left_1");
				var left_2=document.getElementById("left_2");
				var tab=document.getElementById("tab");
				
				if (logo.style.display == "none") {
				      logo.style.height = "72px"; 
					  logo.style.display = "block";
					  meun.style.top = "72px";
					  left_1.style.top = "102px";
					  left_2.style.top = "102px";
					  tab.style.top = "102px";
				  }	else {
					logo.style.height = "0px"; 
					logo.style.display = "none";
					meun.style.top = "0px";
					left_1.style.top = "30px";
					left_2.style.top = "30px";
					tab.style.top = "30px";
				  }
				resizeIFrame();
			}
			
		  </script>	

	</head>	
	<body style="overflow: hidden;">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" id="R_All">
			<tr>
				<td valign="top">
					<div class="top">			
					<div id="logo_top" class="logo_top">
 					   	<table width="100%" border="0" cellpadding="0" cellspacing="0">
    					 	<tr>
 					     		<td>
 					      			<div id="logo_top_1"></div>
 					     		</td>
 					      		<td align="right" valign="bottom" id="change">
					      			<table width="300" align="right" border="0" cellpadding="0" cellspacing="0" id="changeThemes" style="display:none">
					        			<tr align="right">
 					        				<td valign="bottom" align="right">
    					    					<span class="menu1" id="themesSpan">
													<c:forEach items="${themes}" var="item">
														<a href="javascript:void(0);" id="${item.enName}" onclick="switchThemes(this);" title="${item.name}">${item.name}</a>&nbsp;&nbsp;
													</c:forEach>
        					 					</span>
     					      				</td>
     					      			</tr>
      					    		</table>
      					    		<table width="300" align="center" border="0" cellpadding="0" cellspacing="0" id="changeRole"  style="display:none">
         					  			<tr>
	           					   			<td align="right" valign="middle">
		           					   			<c:forEach items="${sessionScope.roleList}" var="item" varStatus="status">
													<c:choose>
														<c:when test="${sessionScope.role.id==item.id}">
													   		<label class="menu2" id="roleRadioSpan">
			       					        					<input type="radio" name="roleRadio" onclick="changeRole('roleRadio');" value="${item.id}" checked="checked" id="RadioGroup1_${status.index}"/>${item.name}
			       					        				</label>
													   	</c:when> 
													   	<c:otherwise>
													   		<label class="menu2" id="roleRadioSpan">
			       					        					<input type="radio" name="roleRadio" onclick="changeRole('roleRadio');" value="${item.id}" id="RadioGroup1_${status.index}"/>${item.name}
			       					        				</label>
													   	</c:otherwise>  
													</c:choose>
												</c:forEach>
	     					        		</td>
    					      	 		</tr>
    					      		</table>
    					     	</td>
    						</tr>
     					</table>
    				</div>
					<div class="menu" id="menu">
						<div id="menu01">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="25" height="23" align="center" valign="bottom">
										<img  src="<at:url image="biao.png"/>" onClick="T_flex()" width="16" height="16" id="max_min" />
									</td>
									<td height="20" valign="bottom" class="font_01">
										<div class="state_doctor">													
											<span title="${sessionScope.organ.name}">${sessionScope.organ.name}：</span>
											<span title="${sessionScope.role.name}">${sessionScope.man.name}</span>
											<span title="${sessionScope.man.qualification.name}">【${sessionScope.man.duty.name}】</span>																					
										</div>
									</td>
								</tr>
							</table>
						</div>
						<div id="menu02">
							<div class="menu02_1" id="menu02_1">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td width="20" height="25" valign="bottom">
											<img src="<at:url image="zoom.png"/>" onclick="popup_show()" width="16" height="16"/>
										</td>
										<td height="25" valign="bottom" class="menu2">
											<a href="#" onclick="popup_show()">小助手</a>																																	
											<div class="sample_popup" id="popup" style="visibility: hidden; display: none; background: white;">											
											<table width="540" border="1" cellspacing="0" cellpadding="1">
												<tr>
													<td class="BT_06" id="mi_01" height="100">
														<div class="menu_form_header" id="popup_drag">
														<img class="menu_form_exit" id="popup_exit" src="<at:url image="close.png"/>" align="right"/>
														     小助手
														</div>
														<table width="100%" border="0" cellspacing="0" cellpadding="4" class="menu_form_header">
															<tr>
																<td width="20%" align="center">
																	<img src="<at:url image="oams.gif"/>" width="75" height="94"/>
																</td>
																<td width="80%" id="helpFont">
																	<table width="100%" border="0" cellspacing="0" cellpadding="1">
																		<tr>
																			<td class="Biaoti_4">
																				小秘书提醒你：今天无待办公文
																			</td>
																		</tr>
																		<tr>
																			<td style="border-bottom: dashed 1px #CCCCCC" class="Biaoti_4">
																				<a href="#">·您有 <font color="#ff0000">1</font> 封未读便笺</a>
																			</td>
																		</tr>
																		<tr>
																			<td style="border-bottom: dashed 1px #CCCCCC" class="Biaoti_4">
																				<a href="#">·我的待办中有  <font color="#ff0000">5</font>
																					份公文没有处理！</a>
																			</td>
																		</tr>
																		<tr>
																			<td style="border-bottom: dashed 1px #CCCCCC">
																				<a href="#">·人事管理中有 <font color="#ff0000">3</font>
																					个代办事项！</a>
																			</td>
																		</tr>
																	</table>
																</td>
															</tr>
														</table>
													</td>
												</tr>
											</table>
											</div>				
										</td>
									</tr>
								</table>
							</div>
							<div class="menu02_2" id="menu02_2">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td height="26" valign="bottom" class="menuTime"
											id="mianTime">
											<script type="text/javascript">
									          tick();
								          	</script>
										</td>
										<td width="11%" align="center" valign="bottom"
											class="menu_02">
											<a href="javascript:void(0)" onclick="chageIframe('index!desktop');"">桌面</a>
										</td>
										<td width="11%" align="center" valign="bottom"
											class="menu_02">
											<a href="javascript:void(0)" onclick="chageIframe('/CoolCalendar.html');">日历</a>
										</td>
										<td width="11%" align="center" valign="bottom"
											class="menu_02" id="roleRadio">
											<a href="javascript:void(0)" onclick="display('changeRole','changeThemes')">角色</a>
										</td>
										<td width="11%" align="center" valign="bottom"
											class="menu_02" id="themes">
											<a href="javascript:void(0)" onclick="display('changeThemes','changeRole')" >换肤</a>
										</td>
										<td width="11%" align="center" valign="bottom"
											class="menu_02">
											<a href="javascript:void(0)" onclick="exit();">退出</a>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</div>	
				</div>						
				</td>
			</tr>
			<tr>
				<td height="100%" valign="top">
					<table width="100%" border="0" cellspacing="0" cellpadding="0" id="S_Top">
						<tr>
							<td valign="top" >
								<div id="left_1" class="side" >
									<table width="120" border="0" align="center" cellpadding="0" cellspacing="0">
										<tr>
											<td height="25">&nbsp;												
											</td>
										</tr>
										<tr>
											<td align="center" valign="top">
												<div id="Accordion1" class="Accordion" tabindex="0">
													<c:forEach items="${sessionScope.menu}" var="model" varStatus="status">
														<c:if test="${model.parent.id=='PK0000000000000000001'}">
															<div class="AccordionPanel">
												               	<div class="AccordionPanelTab" id="A${status.index + 1}" onClick="LA=id">${model.name}</div>
												                <div class="AccordionPanelContent" id="SA${status.index + 1}">
												                	<c:forEach items="${sessionScope.menu}" var="fun">
												                		<c:if test="${fun.parent.id==model.id}">
												                			<li class="menu1"><a onclick="chageIframe('${pageContext.request.contextPath}/${fun.url}');" onfocus="this.blur()" href="javascript:void(0)">${fun.name}</a></li>
												                		</c:if>
												                	</c:forEach>
												                </div>
												            </div>
														</c:if>
													</c:forEach>
												</div>
											</td>
										</tr>										
									</table>
								</div>
							</td>
							<td>
								<div id="left_2" class="sida">
									<table id="but" style="margin-top:320px"  width="100" border="0" cellpadding="0" cellspacing="0">
						  				<tr>
						    				<td>
						    					<table width="18px" border="0" cellspacing="0" cellpadding="0">
						      						<tr>
						        						<td height="18px"><div id="topButton" onmousedown="divscrollup(10)" onmouseup="stopScroll()" onmouseout="stopScroll()"></div></td>
						      						</tr>
						     						<tr>
						        						<td height="50px"><div id="LButton" onclick="menuControl();"></div></td>
						     						</tr>
						      						<tr>
						        						<td height="18px"><div id="bottomBottom" onmousedown="divscrolldown(10)" onmouseup="stopScroll()" onmouseout="stopScroll()"></div></td>
						     				 		</tr>
						   						</table>
											</td>
						  				</tr>
						  			</table>
								</div>
							</td> 
							<td align="center" valign="middle">
								<div id="tab" class="main">
									<div id="desktopDive" style="width:100%;height:100%;border:0;">
										<iframe id="desktopFrame" name="desktopFrame" src="desktop.jsp" 
										 marginwidth="0" marginheight="0" frameborder="0" scrolling="no"
											style="z-index:-999;width:100%;"></iframe>
									</div>
								</div>
							</td>
						</tr>
					</table>
				</td>
			</tr>

			<tr>
				<td height="28px" valign="bottom" class="bottom">
					<div id="bottom"></div>
				</td>
			</tr>
			
		</table>
		<script type="text/javascript">			
			var Accordion1 = new Spry.Widget.Accordion("Accordion1");			
		</script>
	</body>
</html>
